﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace park.SIM
{
    public partial class SIMRecharge : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.labCodel.Text= fix("code");
                this.labTel.Text = fix("telephone");
            }
        }

        string fix(string key)
        {
            if (Request.Params[key] != null)
            {
                try
                {
                    return Uri.UnescapeDataString(Request.Params[key]);
                }
                catch
                {
                    return Request.Params[key];
                }
            }
            return "";
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            #region 正式代码
            string strCode = this.labCodel.Text;
            string strTel = this.labTel.Text;
            decimal mMoney = 0.00M;
            decimal.TryParse(this.txtMoney.Text, out mMoney);

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
            bool flag = sl.AddSIMRecord(strCode, strTel,mMoney, "test", DateTime.Now.ToString());

            string msg = flag ? "数据保存成功！" : "数据保存失败，请重试...";

            Page.ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), "<script>alert('" + msg + "');</script>");
            #endregion
        }
    }
}